function test(){
  var num = 1024;
  function add(){
        num++;
        console.log(num);
  }
  return {num :num,add:add}
}

var res1 = test();
var res2 = test();
res1.add();
res1.add();
console.log(res1.num)
res2.add()